package br.com.mayco.controller;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * @author Mayco Lucian
 * @since 25/02/2013
 * @version 1.0.0
 */
class Messages implements Serializable {


    // <editor-fold defaultstate="collapsed" desc="message">

    // <editor-fold defaultstate="collapsed" desc="addInfo">
    public void addInfo(String summary) {
        addInfo(summary, null);
    }

    public void addInfo(String summary, String detail) {
        addMessage(summary, detail, FacesMessage.SEVERITY_INFO);
    }// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="addError">
    public void addError(String summary) {
        addError(summary, null);
    }

    public void addError(String summary, String detail) {
        addMessage(summary, detail, FacesMessage.SEVERITY_ERROR);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="addFatal">
    public void addFatal(String summary) {
        addFatal(summary, null);
    }

    public void addFatal(String summary, String detail) {
        addMessage(summary, detail, FacesMessage.SEVERITY_FATAL);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="addWarning">
    public void addWarn(String summary) {
        addWarn(summary, summary);
    }

    public void addWarn(String summary, String detail) {
        addMessage(summary, detail, FacesMessage.SEVERITY_WARN);
    }// </editor-fold>

    public void addMessage(String summary, String detail, FacesMessage.Severity severity) {
        addMessage(summary, detail, severity, null);
    }

    public void addMessage(String summary, String detail, FacesMessage.Severity severity, String clientId) {
        FacesMessage msg = new FacesMessage(severity, summary, detail);
        FacesContext.getCurrentInstance().addMessage(clientId, msg);
    }
    // </editor-fold>
}
